// https://www.acwing.com/problem/content/801/

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

/*
20
7 10 10 4 3 9 7 2 5 5 0 6 6 8 5 2 10 6 5 8

[7]
*/
int main() {
    int n;
    cin>>n;
    vector<int> nums(n);
    for (int i=0; i<n; i++) {
        cin>>nums[i];
    }

    vector<int> dict(100005);
    int result = 0;
    int start = 0;
    for (int i=0; i<n; i++) {
        // 这个地方需要确定关注窗口的位置，<= start 即可，表示以前已经出现的数不考虑了
        if (dict[nums[i]] <= start) {
            dict[nums[i]] = i+1;
            result = max(result, i - start + 1);
        } else {
            start = dict[nums[i]];
            dict[nums[i]] = i+ 1;
        }
    }
    cout<<result<<endl;
    return 0;
}
